# Contributor: Oleg Titov <oleg.titov@gmail.com>
# Maintainer: Oleg Titov <oleg.titov@gmail.com>
pkgname=xmrig
pkgver=6.3.1
pkgrel=0
pkgdesc="XMRig is a high performance Monero (XMR) miner"
url="https://xmrig.com/"
arch="all !s390x !ppc64le !aarch64 !mips !mips64" # gets stuck on aarch64 builder
arch="$arch !armv7" # armv7 fails to build on CI
arch="$arch !armhf" # Fails on the builders
license="GPL-3.0-or-later"
options="!check" # No test suite from upstream
makedepends="cmake libmicrohttpd-dev libuv-dev openssl-dev hwloc-dev"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/xmrig/xmrig/archive/v$pkgver.tar.gz"

case "$CARCH" in
	aarch64*) CMAKE_CROSSOPTS="-DARM_TARGET=8"; makedepends="$makedepends linux-headers" ;;
	armv7*)   CMAKE_CROSSOPTS="-DARM_TARGET=7"; makedepends="$makedepends linux-headers" ;;
	armhf*)   CMAKE_CROSSOPTS="-DARM_TARGET=7"; makedepends="$makedepends linux-headers" ;;
esac

build() {
	cmake -B build $CMAKE_CROSSOPTS -DCMAKE_BUILD_TYPE=None \
		-DWITH_CUDA=OFF \
		-DWITH_OPENCL=OFF

	make -C build
}

package() {
	install -Dm 755 build/xmrig $pkgdir/usr/bin/xmrig

	install -Dm 644 -t "$pkgdir"/usr/share/doc/$pkgname/ README.md
}

sha512sums="6ac595a5ab7288856494fc20c08fd6fc4177994e951a102b6ed307a2bd261d7679e619b55e92d429b13de2bf95bac0817b25512f46ef188488fcc5ed0c8f4586  xmrig-6.3.1.tar.gz"
